<!--系统管理-->
<?php include('header.php') ;
						$person=$_SESSION['user'];
						$q=$person->getauth();
						$have=in_array('a3',$q);
						if (!$have){
						$url = "/libraryoa/view/login.php";
  						Header("Location: $url");
						}
?>
 <div id="mainbody"> 
   <div class="col-lg-9" id="charge"> 
    <div class="panel panel-primary"> 
     <div class="panel-heading"> 
      <h3 class="panel-title">用户管理</h3> 
     </div> 
     <div class="panel-body"> 
      <ul id="myTab" class="nav nav-tabs" style="margin-bottom:20px;"> 
       <li class="active"><a href="#workuser" data-toggle="tab"> 在职学生</a></li> 
        <li><a href="tatwork.php"> 在职老师</a></li> 
	<li><a href="addT.php" >添加老师</a></li> 
      </ul> 
      <div id="myTabContent" class="tab-content"> 
       <div class="tab-pane fade in active" id="workuser"> 
          
       <table class="table" id="work-table">
       <tr id="table-nav">
 
        <td>  学号</td>
        <td>  姓名</td>
        <td>学院</td>
        <td></td>
        <td>操作 </td>
        <td></td>
       </tr>
<?php

function table(){
// 	$sql="select * from $tabname";
	$sql = " drop table if exists tmp_student_info";
	mysql_query($sql);
	$sql1 = "create table tmp_student_info (studentid char(11),studentname varchar(20),
		college varchar(35)) default charset = utf8";
	mysql_query($sql1) or die("22222");
	$sql="insert into tmp_student_info SELECT studentworkinlibrary.studentid,studentname,college FROM allstudent join studentworkinlibrary on studentworkinlibrary.studentid=allstudent.studentid and stillwork='yes'";
	mysql_query($sql)or die("11111");
	$sql2="select * from tmp_student_info";
	$result=mysql_query($sql2);
	if ($result==null){
		echo "结果为空!";
	}
	
	$url="sysadmin.php";
	//每页显示的记录条数
	$num=10;
	//sql结果集记录总条数
	$total=mysql_num_rows($result)or die("sql执行失败！");
	//ceil()函数,向上取整. 总页码
	$pagenum=ceil($total/$num);
	//确定当前页码.
	$cpage=isset($_GET["page"])?$_GET["page"]:1;
	//limit偏移量
	$offset=($cpage-1)*$num;
	$sql="select * from tmp_student_info limit {$offset},{$num}";
	$result=mysql_query($sql);
	//当前页起始记录
	$start=$offset+1;
	//当前页最后一条记录
	$end=($cpage==$pagenum)?$total:($cpage*$num);
	//上一页
	$prev=($cpage==1)?0:($cpage-1);
	//下一页
	$next=($cpage==$pagenum)?0:($cpage+1);
		
	$rows=mysql_num_rows($result);
	$cols=mysql_num_fields($result);
	//输出值
	while($row=mysql_fetch_array($result)){
	$surl='authority.php?studentid='.$row["studentid"].'&studentname='.$row["studentname"].'';
	$sur2='leave.php?sid='.$row["studentid"].'&sname='.$row["studentname"].'';
		echo '<tr >';
		echo '<td>'.$row["studentid"].'</td>';
		echo  '<td>'.$row["studentname"] .'</td>';
		echo  '<td>'.$row["college"] .'</td>';
		echo  '<td><a href='.$surl.'>权限</a></td>';
		echo '<td><a href='.$sur2.'>离职</td>';
		echo '</tr>';
	}
	echo '<tr align="center"><td colspan="'.$cols.'">';
	echo "共：{$total}条记录，当前显示：{$start}-{$end}，当前页面：{$cpage}/{$pagenum}";
	//判断"首页"按钮是否可用.
	if($cpage==1)
		echo "&nbsp;&nbsp;首页&nbsp;&nbsp;";
	else
		echo "&nbsp;&nbsp;<a href='{$url}?page=1'>首页</a>&nbsp;&nbsp;";
	//判断上一页是否可用
	if($prev)
		echo "&nbsp;&nbsp;<a href='{$url}?page={$prev}'>上一页</a>&nbsp;&nbsp;";
	else
		echo "&nbsp;&nbsp;上一页&nbsp;&nbsp;";
	//判断下一页是否可用
	if($next)
		echo "&nbsp;&nbsp;<a href='{$url}?page={$next}'>下一页</a>&nbsp;&nbsp;";
	else
		echo "&nbsp;&nbsp;下一页&nbsp;&nbsp;";
	//判断"尾页"按钮是否可用
	if($cpage==$pagenum)
		echo "&nbsp;&nbsp;尾页&nbsp;&nbsp;";
	else
		echo "&nbsp;&nbsp;<a href='{$url}?page={$pagenum}'>尾页</a>&nbsp;&nbsp;";
	echo '</tr></td>';
	echo '</table>';
	mysql_free_result($result);
	mysql_close();
}
table();
?> 
     </table>
       </div> 
       <div class="tab-pane fade" id="useradd"> 
       </div> 
      </div> 
      </div>
      </div>
      </div>
     

   <div class="col-lg-3" > 
    <div class="list-group"> 
     <a href="#" class="list-group-item">用户管理</a> 
    </div> 
   </div> 
  </div>
 
  <footer> 
   <div> 
    <div class="panel panel-default" id="foot"> 
     <div class="panel-body">
       版权信息 &copy; 2014, 云南大学图书馆 
     </div> 
    </div> 
   </div> 
  </footer>  
 </body>
</html>